package picol.view.component;

import java.awt.Color;
import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

public class TableCounter extends DefaultTableCellRenderer {

    private static ImageIcon image;

    TableCounter() {
        super();
        this.image = new ImageIcon(getClass().getResource("/picol/view/images/circle.png"));
    }

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {


        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

        if (!(value instanceof String)) {
            Boolean test = (Boolean) value;
            setText("");
            if (test) {
                setIcon(null);
            } else {
                setIcon(image);
            }
        }




        return this;
    }

    public void setCouleurComposant(Component composant, Color couleur) {

        composant.setBackground(couleur);
        composant.setForeground(Color.black);
    }
}
